<?php

namespace Admin\Controller;

use Think\Controller;

class CustomerController extends Controller
{
    public function index()
    {
        $nickname = I('get.nickname');
        $mobile = I('get.mobile');
        $birthday = I('get.birthday');
        $Customer = M('Customer');
        $map = [];
        if (isset($nickname)) {
            $map['nickname'] = array('like', '%' . $nickname . '%');//按昵称
        }
        if (isset($mobile)) {
            $map['mobile'] = array('like', '%' . $mobile . '%');//按手机号码
        }
        if (isset($birthday)) {
            $map['birthday'] = array('like', '%' . $birthday . '%');//按生日时间
        }
        $count = $Customer->count(); //查出满足要求的记录数
        $Page = new \Common\Util\Page($count, 5);// 实例化分页类 传入总记录数和每页显示的记录数
        $customers = $Customer->where($map)->order('created_at desc')->
        limit($Page->firstRow . ',' . $Page->listRows)->select();
        $pages = $Page->show();//分页显示输出
        $this->assign(compact('customers','pages','count'));
        $this->display();
}
}